package com.download.backstage.controller;

import com.download.web.entity.BusFriendLink;
import com.download.web.entity.model.Page;
import com.download.web.entity.model.Result;
import com.download.web.service.IBusFriendLinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/backstage/friendLink")
public class BusFriendLinkController {
    @Autowired
    private IBusFriendLinkService friendLinkService;

    @ResponseBody
    @RequestMapping("/addFriendLink")
    public Result addFriendLink(@RequestBody BusFriendLink busFriendLink){
        friendLinkService.save(busFriendLink);
        return Result.ok(null);
    }
    @ResponseBody
    @RequestMapping("/delFriendLink")
    public Result delFriendLink(Integer id){
        friendLinkService.removeById(id);
        return Result.ok(null);
    }
    @ResponseBody
    @RequestMapping("/updateFriendLink")
    public Result updateFriendLink(@RequestBody BusFriendLink busFriendLink){
        friendLinkService.updateById(busFriendLink);
        return Result.ok(null);
    }
    @ResponseBody
    @RequestMapping("/friendLinkById")
    public Result friendLinkById( Integer id){
        BusFriendLink friendLink=friendLinkService.getById(id);
        return Result.ok(friendLink);
    }

    @ResponseBody
    @RequestMapping("/friendLinkPage")
    public Page<BusFriendLink> friendLinkById(@RequestParam(name = "pageIndex",defaultValue = "0") Integer pageIndex, @RequestParam(value = "pageSize",defaultValue = "20")Integer pageSize){
        Page<BusFriendLink> friendLink=friendLinkService.friendLinkPage(pageIndex,pageSize);
        return friendLink;
    }

}
